﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pro_PoDataList.aspx.cs" Inherits="ArtLand.OA.Project.Project.Pro_PoDataList" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../css/admin.css" rel="stylesheet" />
    <script src="../js/WebCommon.js"></script>
    <script src="../js/jquery-1.4.1.min.js"></script>
    <style>
        .mygrid-row-summary.x-grid3-row {
            background-color: #efefef !important;
            background-image: none !important;
            border-color: #fff #ededed #ededed !important;
            visibility: hidden;
        }

            .mygrid-row-summary.x-grid3-row .x-grid3-td-numberer, .mygrid-row-summary.x-grid3-row .x-grid3-td-checker {
                background-image: none !important;
            }

                .mygrid-row-summary.x-grid3-row .x-grid3-td-numberer .x-grid3-col-numberer, .mygrid-row-summary.x-grid3-row .x-grid3-td-checker .x-grid3-col-checker {
                    display: none;
                }

            .mygrid-row-summary.x-grid3-row td {
                font-size: 14px;
                line-height: 16px;
                font-weight: bold;
                color: blue;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <ext:PageManager ID="PageManager1" runat="server" AutoSizePanelID="pan1" />
        <ext:Panel ShowBorder="false" ShowHeader="false" runat="server" ID="pan1" Layout="Fit">
            <Toolbars>
                <ext:Toolbar ID="Toolbar2" runat="server">
                    <Items>
                        <ext:TwinTriggerBox ID="ttbxMyBox2" ShowLabel="false" OnTrigger1Click="ttbxMyBox2_Trigger1Click"
                            OnTrigger2Click="ttbxMyBox2_Trigger2Click" Trigger1Icon="Clear" ShowTrigger1="False"
                            EmptyText="请输入合同编号或采购订单号" Trigger2Icon="Search" runat="server" Width="180px">
                        </ext:TwinTriggerBox>
                    </Items>
                </ext:Toolbar>
            </Toolbars>
            <Items>
                <ext:Grid ID="Grid1" Title="采购订单管理" ShowHeader="false" ShowBorder="false" runat="server" EnableCheckBoxSelect="false" DataKeyNames="ID,STATUS"
                    OnRowDataBound="Grid1_RowDataBound" EnableRowSelect="true" OnRowSelect="Grid1_RowSelect" AllowPaging="true" IsDatabasePaging="true" PageSize="10" OnPageIndexChange="Grid1_PageIndexChange" EnableRowDoubleClick="true" OnRowDoubleClick="Grid1_RowDoubleClick" OnRowCommand="Grid1_RowCommand" EnableColumnLines="true">
                    <Toolbars>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:Button ID="btnNew" Text="添加" Icon="Add" EnablePostBack="false" runat="server">
                                </ext:Button>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:Button ID="Button1" Text="修改" OnClick="Button1_Click" Icon="ApplicationEdit" runat="server">
                                </ext:Button>
                                <ext:Button ID="Button2" Text="删除" OnClick="Button2_Click" Icon="Delete" runat="server" ConfirmText="您确定要这么做吗？">
                                </ext:Button>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:Button ID="btnMoney" runat="server" EnablePostBack="false" Icon="Money" Text="付款操作">
                                    <Menu>
                                        <ext:MenuButton ID="btnMoneyAdd" runat="server" OnClick="btnMoneyAdd_Click" Icon="MoneyAdd" Text="新增付款记录"></ext:MenuButton>
                                        <ext:MenuButton ID="btnMoneyView" runat="server" OnClick="btnMoneyView_Click" IconUrl="~/icon/application-list.png" Text="查看采购付款记录"></ext:MenuButton>
                                    </Menu>
                                </ext:Button>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:Button ID="Button3" runat="server" EnablePostBack="false" Icon="Lorry" Text="送货计划">
                                    <Menu>
                                        <ext:MenuButton runat="server" ID="MenuButton1" Icon="LorryAdd" Text="创建送货计划" OnClick="MenuButton1_Click"></ext:MenuButton>
                                        <ext:MenuButton runat="server" ID="MenuButton2" Icon="LorryGo" Text="查看送货计划记录" OnClick="MenuButton2_Click"></ext:MenuButton>
                                    </Menu>
                                </ext:Button>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:Button runat="server" ID="btn_Search" Text="采购订单报表查询" OnClick="btn_Search_Click" Icon="Find"></ext:Button>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:Button runat="server" ID="btn_Pring" Text="打印" OnClick="btn_Pring_Click" Icon="Printer" OnClientClick="window.open('Pro_PoDataPrint.aspx');"></ext:Button>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:ToolbarText ID="ToolbarText2" runat="server" Enabled="false" Text=""></ext:ToolbarText>
                                <ext:ToolbarSeparator></ext:ToolbarSeparator>
                                <ext:ToolbarText ID="ToolbarText1" runat="server" Enabled="false" Text="<span style='color:#999'>双击可添加付款记录</span>"></ext:ToolbarText>



                            </Items>
                        </ext:Toolbar>
                    </Toolbars>
                    <Columns>
                        <ext:BoundField Width="85px" DataField="PONBER" DataFormatString="{0}" HeaderText="采购订单号" />
                        <ext:BoundField Width="85px" DataField="AddTime" DataFormatString="{0:yyyy-MM-dd}" HeaderText="订单日期" TextAlign="Center" />
                        <ext:BoundField Width="75px" DataField="POTYPE" Hidden="true" DataFormatString="{0}" HeaderText="订单类型" TextAlign="Center" />
                        <ext:BoundField Width="100px" DataField="CONNUB" DataFormatString="{0}" HeaderText="合同编号" TextAlign="Center" />
                        <ext:BoundField Width="95px" DataField="VEDNUB" DataFormatString="{0}" HeaderText="供应商编号" TextAlign="Center" />
                        <ext:BoundField Width="75px" ColumnID="major" DataField="VEDNUB" DataFormatString="{0}" HeaderText="供应商简称" TextAlign="Center" />
                        <ext:BoundField Width="160px" ColumnID="donate" DataField="TAMOUT" DataFormatString="{0}" HeaderText="采购金额" TextAlign="Center" />
                        <ext:BoundField Width="160px" ColumnID="fee" DataField="ID" DataFormatString="{0}" HeaderText="未付金额" TextAlign="Center" />
                        <ext:BoundField Width="60px" DataField="REQTOR" DataFormatString="{0}" HeaderText="申请人" TextAlign="Center" />
                        <ext:BoundField Width="80px" DataField="DLDATE" DataFormatString="{0:yyyy-MM-dd}" HeaderText="交货日期" TextAlign="Center" />
                        <ext:BoundField Width="70px" DataField="PATYPE" DataToolTipField="PATYPE" DataFormatString="{0}" HeaderText="付款方式" TextAlign="Center" />
                        <ext:BoundField Width="85px" DataField="VEDNNBNo" DataFormatString="{0}" HeaderText="供应商订单号" TextAlign="Center" />
                        <ext:BoundField Width="60px" DataField="STATUS" DataFormatString="{0}" HeaderText="状态" TextAlign="Center" />
                        <ext:CheckBoxField ColumnID="CheckBoxField4" Width="70px" RenderAsStaticField="false"
                            AutoPostBack="true" CommandName="CheckBox1" DataField="IsShou" HeaderText="收货状态"
                            ToolTip="是否已经收货完成" TextAlign="Center" />
                        <ext:CheckBoxField Width="70px" DataField="IsShou" RenderAsStaticField="true" HeaderText="收货完成" TextAlign="Center" />

                        <ext:WindowField ColumnID="myWindowField" Width="80px" WindowID="Window1" DataTextFormatString="{0}" DataIFrameUrlFields="ID"
                            DataIFrameUrlFormatString="Pro_PoDataChange.aspx?id={0}&s=1" DataWindowTitleField="PONBER"
                            DataWindowTitleFormatString="审批采购订单" TextAlign="Center" HeaderText="操作" Text="进行审批" />
                    </Columns>
                </ext:Grid>
            </Items>
        </ext:Panel>

        <ext:Window ID="Window3" Title="编辑" Popup="false" runat="server"
            CloseAction="HidePostBack" Target="Self" IsModal="false" Width="320px" Height="200px">
            <Toolbars>
                <ext:Toolbar Position="Footer">
                    <Items>
                        <ext:Button runat="server" ID="btn_Save" Text="查询" Icon="Find" OnClick="btn_Save_Click"></ext:Button>
                    </Items>
                </ext:Toolbar>
            </Toolbars>
            <Items>
                <ext:Panel ShowBorder="false" ShowHeader="false" Height="180px" EnableBackgroundColor="true">
                    <Items>
                        <ext:Panel ID="Panel3" ShowHeader="false" ShowBorder="false"
                            Layout="Column" runat="server" EnableBackgroundColor="true" BodyPadding="10px">
                            <Items>
                                <ext:Label ID="Label3" Text="合同编号：" Width="75px" runat="server" ShowLabel="false">
                                </ext:Label>
                                <ext:TextBox runat="server" ID="txt_CONNUB" Label="合同编号"></ext:TextBox>
                            </Items>
                        </ext:Panel>

                        <ext:Panel ID="Panel2" ShowHeader="false" ShowBorder="false"
                            Layout="Column" runat="server" EnableBackgroundColor="true" BodyPadding="10px">
                            <Items>
                                <ext:Label ID="Label2" Text="供应商编号：" Width="75px" runat="server" ShowLabel="false">
                                </ext:Label>
                                <ext:TextBox runat="server" ID="txt_VEDNUB" Label="供应商编号"></ext:TextBox>
                            </Items>
                        </ext:Panel>

                        <ext:Panel ID="Panel1" ShowHeader="false" ShowBorder="false"
                            Layout="Column" runat="server" EnableBackgroundColor="true" BodyPadding="10px">
                            <Items>
                                <ext:Label ID="Label1" Text="交货时间：" Width="75px" runat="server" ShowLabel="false">
                                </ext:Label>
                                <ext:DatePicker runat="server" Width="90px" Label="开始日期" ID="txt_StartTime" EnableDateSelect="true">
                                </ext:DatePicker>
                                <ext:Label Text="&nbsp;&nbsp;至&nbsp;&nbsp;">
                                </ext:Label>
                                <ext:DatePicker ID="txt_EndTime" Width="90px" Label="结束日期" DateFormatString="yyyy-MM-dd" runat="server"
                                    EnableDateSelect="true">
                                </ext:DatePicker>
                            </Items>
                        </ext:Panel>


                    </Items>
                </ext:Panel>

            </Items>
        </ext:Window>


        <ext:Window ID="Window1" Title="编辑" Popup="false" EnableIFrame="true" runat="server"
            CloseAction="HidePostBack" EnableConfirmOnClose="true" IFrameUrl="about:blank" Target="Top" IsModal="True" Width="520px" Height="500px">
        </ext:Window>
        <ext:Window ID="Window2" Title="编辑" Popup="false" EnableIFrame="true" runat="server"
            CloseAction="HidePostBack" EnableConfirmOnClose="true" IFrameUrl="about:blank" Target="Top" IsModal="True" Width="520px" Height="490px">
        </ext:Window>
        <ext:Window ID="Window4" Title="编辑" Popup="false" EnableIFrame="true" runat="server"
            CloseAction="HidePostBack" EnableConfirmOnClose="true" IFrameUrl="about:blank" Target="Top" IsModal="True" Width="605px" Height="350px">
        </ext:Window>
        
    </form>
    <script src="../js/extgridbug.js"></script>
    <script>
        var n = false;
        var gridClientID = '<%= Grid1.ClientID %>';

        var gridSummaryID = '<%=t %>';
        function customsummary(idt, clietid) {
            
                var grid = X(clietid);
                console.log("1");
                var donateTotal = 0, store = grid.getStore(), view = grid.getView(), storeCount = store.getCount();
                console.log("2");
              // console.log(Ext.get(view.getRow(storeCount - 1)));
                // 防止重复添加了合计行
                //if (Ext.get(view.getRow(storeCount - 1)).hasClass('mygrid-row-summary')) {
                //    return;
                //}
                //alert(storeCount);
                // alert(gridSummaryID);
                // 从隐藏字段获取全部数据的汇总
                var summaryJSON = JSON.parse(idt);


                store.add(new Ext.data.Record({
                    'major': '合计',
                    'donate': summaryJSON['donateTotal'].toFixed(2),
                    'fee': summaryJSON['feeTotal'].toFixed(2)
                }));

                
                // 为合计行添加自定义样式（隐藏序号列、复选框列，取消 hover 和 selected 效果）
                var summaryNode = Ext.get(view.getRow(storeCount)).addClass('mygrid-row-summary');

                // 找到合计行的外部容器节点
                var viewportNode = summaryNode.parent('.x-grid3-viewport');
                // 删除容器节点下直接子节点为 mygrid-row-summary 的节点
                viewportNode.select('> .mygrid-row-summary').remove();

                // 创建合计行的副本
                var cloneSummaryNode = summaryNode.dom.cloneNode(true);
                // 修改合计行的副本的样式，绝对定位，距离底部0px，显示副本（默认是占位隐藏 visibility: hidden;）
                Ext.get(cloneSummaryNode).setStyle({
                    position: 'absolute',
                    bottom: 0,
                    visibility: 'visible'
                });
                
                // 向容器节点添加合计行的副本
                viewportNode.appendChild(cloneSummaryNode);
                console.log("3");
        }


        function calcGridSummary(grid) {
            var donateTotal = 0, store = grid.getStore(), view = grid.getView(), storeCount = store.getCount();

            // 防止重复添加了合计行
       
            if (Ext.get(view.getRow(storeCount - 1)).hasClass('mygrid-row-summary')) {
                return;
            }
            // alert(gridSummaryID);
            // 从隐藏字段获取全部数据的汇总
            var summaryJSON = JSON.parse(gridSummaryID);


            store.add(new Ext.data.Record({
                'major': '合计',
                'donate': summaryJSON['donateTotal'].toFixed(2),
                'fee': summaryJSON['feeTotal'].toFixed(2)
            }));


            // 为合计行添加自定义样式（隐藏序号列、复选框列，取消 hover 和 selected 效果）
            var summaryNode = Ext.get(view.getRow(storeCount)).addClass('mygrid-row-summary');

            // 找到合计行的外部容器节点
            var viewportNode = summaryNode.parent('.x-grid3-viewport');
            // 删除容器节点下直接子节点为 mygrid-row-summary 的节点
            viewportNode.select('> .mygrid-row-summary').remove();

            // 创建合计行的副本
            var cloneSummaryNode = summaryNode.dom.cloneNode(true);
            // 修改合计行的副本的样式，绝对定位，距离底部0px，显示副本（默认是占位隐藏 visibility: hidden;）
            Ext.get(cloneSummaryNode).setStyle({
                position: 'absolute',
                bottom: 0,
                visibility: 'visible'
            });

            // 向容器节点添加合计行的副本
            viewportNode.appendChild(cloneSummaryNode);

        }

        // 页面第一个加载完毕后执行的函数
        function onReady() {
            var grid = X(gridClientID);
            grid.addListener('viewready', function () {
                calcGridSummary(grid);
                //__doPostBack('pan1$Grid1$Toolbar1$btnsss', '');
            });

            // 防止选中合计行
            grid.getSelectionModel().addListener('beforerowselect', function (sm, rowIndex, keepExisting, record) {
                if (Ext.get(grid.getView().getRow(rowIndex)).hasClass('mygrid-row-summary')) {
                    return false;
                }
                return true;
            });
        }

        // 页面AJAX回发后执行的函数
        function onAjaxReady() {
            var grid = X(gridClientID);
            calcGridSummary(grid);
            // alert("1");
            
         
           
           // return false;
        }

        function ts()
        {
            alert("1");
        }

    </script>
</body>
</html>
